package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchMeasurementPoint;
import com.ruoyi.system.service.IDispatchMeasurementPointService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 测点信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchMeasurementPoint")
public class DispatchMeasurementPointController extends BaseController
{
    @Autowired
    private IDispatchMeasurementPointService dispatchMeasurementPointService;

    /**
     * 查询测点信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMeasurementPoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchMeasurementPoint dispatchMeasurementPoint)
    {
        startPage();
        List<DispatchMeasurementPoint> list = dispatchMeasurementPointService.selectDispatchMeasurementPointList(dispatchMeasurementPoint);
        return getDataTable(list);
    }

    /**
     * 导出测点信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMeasurementPoint:export')")
    @Log(title = "测点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchMeasurementPoint dispatchMeasurementPoint)
    {
        List<DispatchMeasurementPoint> list = dispatchMeasurementPointService.selectDispatchMeasurementPointList(dispatchMeasurementPoint);
        ExcelUtil<DispatchMeasurementPoint> util = new ExcelUtil<DispatchMeasurementPoint>(DispatchMeasurementPoint.class);
        util.exportExcel(response, list, "测点信息数据");
    }

    /**
     * 获取测点信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMeasurementPoint:query')")
    @GetMapping(value = "/{measurementPointId}")
    public AjaxResult getInfo(@PathVariable("measurementPointId") Long measurementPointId)
    {
        return success(dispatchMeasurementPointService.selectDispatchMeasurementPointByMeasurementPointId(measurementPointId));
    }

    /**
     * 新增测点信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMeasurementPoint:add')")
    @Log(title = "测点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchMeasurementPoint dispatchMeasurementPoint)
    {
        return toAjax(dispatchMeasurementPointService.insertDispatchMeasurementPoint(dispatchMeasurementPoint));
    }

    /**
     * 修改测点信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMeasurementPoint:edit')")
    @Log(title = "测点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchMeasurementPoint dispatchMeasurementPoint)
    {
        return toAjax(dispatchMeasurementPointService.updateDispatchMeasurementPoint(dispatchMeasurementPoint));
    }

    /**
     * 删除测点信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMeasurementPoint:remove')")
    @Log(title = "测点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{measurementPointIds}")
    public AjaxResult remove(@PathVariable Long[] measurementPointIds)
    {
        return toAjax(dispatchMeasurementPointService.deleteDispatchMeasurementPointByMeasurementPointIds(measurementPointIds));
    }
}
